package funciones;

public class FuncionesProbabilidad {
	/**
	 * @param xx
	 * @return Funcion gamma logaritmo natural de xx
	 */
	static double gammln(double xx){
		double cof[]= new double[6];
		cof[0]=76.18009172947146;
		cof[1]=-86.50532032941677;
		cof[2]=24.01409824083091;
		cof[3]=-1.231739572450155;
		cof[4]=0.1208650973866179e-2;
		cof[5]=-0.5395239384953e-5;
		double x,y,tmp,ser;
		y=x=xx;
		tmp=x+5.5;
		tmp -= (x+0.5)*Math.log(tmp);
		ser=1.000000000190015;
		for (int j=0;j<=5;j++)
			ser += cof[j]/++y;
	
		return -tmp+Math.log(2.5066282746310005*ser/x);
	}
	/**
	 * @param z
	 * @param w
	 * @return funcion beta(z,w)
	 */
	public 	static double beta(double z, double w){
		return Math.exp(gammln(z)+gammln(w)-gammln(z+w));
	}
}
